
const req = require('../../../utils/req.js');
const { api } = require('../../../utils/api.js');

const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderInfo:[],
    addressId:[],
    couponList:[]
  },


  // 点击取消返回购物车
  textOff: function(e) {
    app.jumpToPage('../cart')
  },

  cilok(){
    wx.navigateTo({
      url: '../../person/address/address',
    })
  },

  orderSubmit(){
    let cart_submit = api.cart_submit;
    cart_submit.data.addressId = 948
    cart_submit.data.couponId = 3

    req.ask(cart_submit).then(res => {
      console.log('下单', res);

      
    })
    
      wx.navigateTo({
        url: '../comp/comp',
      })
    

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

    let cart_checkout = api.cart_checkout;
    cart_checkout.data.addressId = options.id;
    cart_checkout.data.couponList = 3
    req.ask(cart_checkout).then(res =>{
        console.log('订单详情页',res);
        this.setData({
          addressId: res.data.data.checkedGoodsList,
          couponList: res.data.data.couponList
        })
      })

    let cart_submit = api.cart_submit;
    cart_submit.data.addressId = 948
    cart_submit.data.couponId = 3

    req.ask(cart_submit).then(res => {
      console.log('提交订单', res.data.data.orderInfo);

      this.setData({
        orderInfo: res.data.data.orderInfo
      })

    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})